package com.starview.star.compiler.util;

import java.io.Serializable;
import java.util.Stack;

@SuppressWarnings("serial")
public class UndoManager implements Serializable
{
  private Stack<UpdateEntry> resetStack = new Stack<UpdateEntry>();

  public void pushUndo(UpdateEntry entry)
  {
    resetStack.push(entry);
  }

  public int getCurrentState()
  {
    return resetStack.size();
  }

  public void resetStack(int state)
  {
    while (resetStack.size() > state) {
      resetStack.pop().reset();
    }
  }
}
